export async function createMap(el, option = {}) {
  const AMap = await AMapLoader.load({
    key: '813eac528498a3200567e0ad0c941a9a',
    plugins: ['AMap.Scale'],
    version: '2.0'
  })

  const scale = new AMap.Scale()

  const map = new AMap.Map(el, {
    center: option.center || void 0,
    zoom: 16
  })

  map.addControl(scale)

  return map
}

const urlParams = new URLSearchParams(window.location.search)

export function getQueryParam(param) {
  return urlParams.get(param)
}

/**
 *
 * @param {number} wait 延时毫秒
 * @returns {Promise<void>}
 */
export function delay(wait) {
  return new Promise(function (resolve) {
    window.setTimeout(resolve, wait)
  })
}
